package cn.cdiothree.converter;

import cn.cdiothree.dto.OrderDto;
import cn.cdiothree.dataobject.ProductOrder;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 将ProductOrder中的信息传入到OrderDTO中
 * @author cumthing
 */
public class ProductOrder2OrderDtoConverter {
    public static OrderDto convert(ProductOrder productOrder){

        OrderDto orderDTO=new OrderDto();

        BeanUtils.copyProperties(productOrder,orderDTO);
        return orderDTO;
    }

    public static List<OrderDto> convert(List<ProductOrder> productOrderList){
        return productOrderList.stream().map(e ->
                convert(e)
                ).collect(Collectors.toList());
    }
}
